package com.smallframework.webserver;

import java.io.IOException;
import java.net.Socket;

/**
 * Description:
 * User: Administrator
 * DateTime: 2017/6/10 0010 11:56
 */
public class Handler implements Runnable {
    private Socket socket;

    public Handler(Socket socket) {
        this.socket = socket;
    }

    @Override
    public void run() {
        try {
            Request request = new Request(socket.getInputStream());
            Response response = new Response(socket.getOutputStream());

            deal(request, response);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private void deal(Request request, Response response) {
        request.parse();
        response.out(request.getUri());
    }
}
